package com.sc.byahi.open.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.sc.byahi.open.shared.LatestState;

public class HomeView extends Composite {

	private static HomeViewUiBinder uiBinder = GWT.create(HomeViewUiBinder.class);

	interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
	}

	public HomeView() {
		initWidget(uiBinder.createAndBindUi(this));
		loginButton.setEnabled(false);
	}

	@UiField
	Anchor loginButton;
	@UiField
	HTML loggedInDesc;
//	@UiField
//	CheckBox terms;

	LatestState state;
	
//	@UiHandler("terms")
//	void onButton_1Click(ClickEvent event) {
//		if(terms.getValue()){
//			loginButton.setStyleName("large button green");
//			loginButton.setHref(state.getLoginURL());
//			loginButton.setEnabled(true);
//		}else{
//			loginButton.setEnabled(false);
//			loginButton.setStyleName("large button gray");
////			loginButton.setHref(Window.Location.getHref());
//			loginButton.setHref("#");
//		}
//	}
	
	public void setLoggedIn(LatestState state) {
		this.state= state ;
		if (!"".equals(state.getCurrentUser())) {
			loggedInDesc.setVisible(true);
		} else {
			loggedInDesc.setVisible(false);
		}
//		loginButton.setStyleName("large button gray");
//		loginButton.setHref("");
		loginButton.setStyleName("large button green");
		loginButton.setHref(state.getLoginURL());
	}

}
